package com.bjsxt.shop.goods.util;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;

import com.bjsxt.shop.common.util.ConstatFinalUtil;
import com.bjsxt.shop.goods.service.ISpliderDataService;

/**
 * Callable 泛型就是我们的返回值
 * @author WangshSxt
 */
public class MyThreadUtil implements Callable<Object>
{
	/* Service里面如何传值给多线程 */
	private Map<String, Object> paramsMap = new HashMap<String,Object>() ;
	
	/* 赋值??? */
	private ISpliderDataService spliderDataService;
	
	@Override
	public Object call() throws Exception
	{
		ConstatFinalUtil.SYS_LOGGER.info("---- call ---当前线程信息:{}-",Thread.currentThread().getName());
		
		/* 取值?
		 * 啥时候放值
		 *  */
		int stPage = Integer.valueOf(paramsMap.get("stPage") + "");
		int edPage = Integer.valueOf(paramsMap.get("edPage") + "");
		/* 调用SplidetDateService中的saveBatchPerPage采集数据
		 * 采集自己的数据
		 * 1-----3
			4-----6
			7-----9
			10-----12
			13-----14
			
			~开始页和结束页如何传递过来
			~如何调用spliderDataService的方法
		 *  */
		for(int i = stPage ; i <= edPage ; i ++)
		{
			this.spliderDataService.saveBatchPerPage(i);
		}
		return null;
	}

	public Map<String, Object> getParamsMap()
	{
		return paramsMap;
	}

	public void setParamsMap(Map<String, Object> paramsMap)
	{
		this.paramsMap = paramsMap;
	}

	public ISpliderDataService getSpliderDataService()
	{
		return spliderDataService;
	}

	public void setSpliderDataService(ISpliderDataService spliderDataService)
	{
		this.spliderDataService = spliderDataService;
	}

}
